package com.neusoft.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.neusoft.bean.User;
import com.neusoft.service.UserService;
import com.neusoft.service.impl.UserServiceImpl;

public class FindUserServlet extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String username = req.getParameter("name");
		UserService  userService = new UserServiceImpl();
		User user = userService.findUserByName(username);
		PrintWriter out = resp.getWriter();
		if(user.getId()!=0){
			out.println("yes");
		}else{
			out.println("no");
		}
		out.flush();
		out.close();
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(req, resp);
	}
	
}
